<?php
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/user/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/tucao/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/mblog/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/album/inc.php");


//所有的参数
$g_cgival 	= array();
//存储中间数据 非输出数据 可以不用
$g_pro	 	= array();
//要显示的数据 输出数据
$g_show 	= array();

function check_cgi_pro()
{		
	global $g_cgival, $g_pro, $g_show, $config;
	
	cgi::both($g_cgival["p"], "p", "");
	$g_cgival["p"] = intval($g_cgival["p"]);
	
	if($g_cgival["p"] < 1) $g_cgival["p"]=1;
	
	cgi::both($g_cgival["id"], "id", 0);
	$g_cgival["id"] = intval($g_cgival["id"]);
	
}


function get_data()
{
	global $g_cgival, $g_pro, $g_show, $config;
	
	$g_show["channel"] = "album";
	$id = intval($g_cgival["id"]);
	$g_show["id"] = $id;
	$g_show["p"] = $g_cgival["p"];
	$g_show["pcount"] = $g_cgival["pcount"]  =  16;
	
	//登录相关
	$user_info = new user_info();
	$is_login = $user_info->is_logined();
	
	$user_info = new user_info();
	$is_login = $user_info->is_logined();
	if($is_login)
	{
		$user_detail_info = $user_info->get_cur_user_info();
		
		$uid = $user_detail_info["uid"];
		$user_nickname = $user_detail_info["user_nickname"];
		$g_show["is_logined"] = true;
		$g_show["current_user_info"] = $user_detail_info;
	}
	/*else
	{
		$url = "/user/login.php?url={$_SERVER["REQUEST_URI"]}";
		header("Location:$url");
	}	*/
	
	
	$db_mblog_cron_topic_tag = new db_mblog_cron_topic_tag();
	$mod_mblog = new mod_mblog();
	
	
	
	if($id)
	{
		$db_album_info = new db_album_info();
		$user_info = new user_info();
		$album_info = $db_album_info->get_album_item($id);
		$album_info["create_time"] = TimeFormatter::timeFormatShort(strtotime($album_info["create_time"]));
		$album_info["user_info"] = $user_info->get_user_info_by_uid($album_info["create_uid"]);
		$album_info["type_name"] = $config["topic_show_type"][$album_info["mblog_show_type"]];
		$page_title = $album_info["title"]."-专辑详细-微博游戏玩家";
	}
	else 
	{
		$page_title = "专辑详细-微博游戏玩家";
		
	}
	$album_info["level"] = $config["album_level"][$album_info["level"]];
	$g_show["album_info"] =$album_info;
	
	$g_show["page_keywords"]  = "{$album_info["title"]},游戏专辑分享,游戏分享,微博玩家,新浪微博玩家,游戏分类专辑,游戏专辑图片";
	$g_show["page_desc"]  = "{$album_info["title"]},分享微博图片专辑,新浪微博玩家发的游戏图片专辑,根据游戏分类推荐专辑";
	$g_show["page_title"] =$page_title;
	

	$g_show["topic_id"] = $g_cgival["topic_id"];
	$g_show["topic_show_type"] = $config["topic_show_type"];
	
	if($album_info["body_url"])
	{
		
		$g_show["body"]["url"] = $album_info["body_url"];
		$g_show["body"]["attach"] = ($album_info["body_attach"] ==1) ? "fixed":"scroll";
		
	}

	$mod_mblog = new mod_mblog();
	$result = $mod_mblog->get_album_pubu_info($g_cgival["p"],$g_cgival["pcount"],$id);
	
	$g_show["list"] = $result["list"];
	$g_show["count"] = $result["count"];
	
	$daohang[] = "<a href='/album/'>专辑</a>";
	if($album_info["mblog_show_type"])$daohang[] = "<a href='/album/?show_type=".$album_info["mblog_show_type"]."'>".$config["topic_show_type"][$album_info["mblog_show_type"]]."</a>";
	if($album_info["mblog_topic"])$daohang[] = "<a href='/album/?topic_id=".$album_info["mblog_topic_id"]."'>".$album_info["mblog_topic"]."</a>";
	if($album_info["user_info"]['user_nickname']) $daohang[] = "<a href='/album/?uid=".$album_info["user_info"]['uid']."'>".$album_info["user_info"]['user_nickname']."的专辑</a>";
	$daohang[] = $album_info["title"];
	$g_show["daohang"] =join(" <i>&gt;</i> ",$daohang);
	
	
	//类型1
	$mod_mblog = new mod_mblog();
	list($list1,$list2,$list3,$list4) = $mod_mblog->get_topic_list_order_by_like();
	$g_show["list1"] = $list1;
	$g_show["list2"] = $list2;
	$g_show["list3"] = $list3;
	$g_show["list4"] = $list4;
	
	
	$create_uid = $album_info["create_uid"];
	$db_album_info = new db_album_info();
	$user_album_list = $db_album_info->get_album_list_by_uid($create_uid,1,10);
	$g_show["user_album_list"] = $user_album_list;
	
	
	
	$Pages = new Pages($g_show["count"],$g_cgival["p"],$g_cgival["pcount"]);
	$g_show["page_bar"] = $Pages->getLinks("?id={$g_cgival["id"]}&p=",100);
	
}

try {
	$g_show['error'] = 0;
	$g_show['errmsg'] = "";
	check_cgi_pro();
	get_data();
	
} catch (Exception $e) {
	$g_show['error'] = 1;
	$g_show['errmsg'] = $e->getMessage();
}

show_pro();


exit;

function show_pro()
{
	global $g_cgival, $g_pro, $g_show, $config;

	$smarty = p_get_smarty();	
	$smarty->assign("g_show", $g_show);
	if (isset($_GET["debug"]))
	{
		print_r($g_show);
	}
	$smarty->display("album/huaban_detail.html");
	
	unset($g_cgival);
	unset($g_pro);
	unset($g_show);
	unset($config);
	
}

